package com.chain.qs.modules.biz.entity;

import com.chain.qs.common.persistence.DataEntity;
import com.chain.qs.common.utils.IdGen;
import com.chain.qs.modules.sys.entity.Office;
import com.chain.qs.modules.sys.entity.User;
import com.chain.qs.modules.sys.utils.UserUtils;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.List;

/**
 * 发射站Entity
 * @author wangzhipiing
 */
public class Station extends DataEntity<Station> {
    private static final long serialVersionUID = 1L;

    private String name;
    private String address;
    private Office office;
    private  String type;
    private String type2;
    private int power;
    private String x;
    private String y;
    private List<EquipmentGroup> equipmentGroups = Lists.newArrayList();


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Office getOffice() {
        return office;
    }

    public void setOffice(Office office) {
        this.office = office;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getType2() {
        return type2;
    }

    public void setType2(String type2) {
        this.type2 = type2;
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        this.power = power;
    }

    public String getX() { return x; }

    public void setX(String x) { this.x = x; }

    public String getY() { return y; }

    public void setY(String y) { this.y = y; }

    public List<EquipmentGroup> getEquipmentGroups() {
        return equipmentGroups;
    }

    public void setEquipmentGroups(List<EquipmentGroup> equipmentGroups) {
        this.equipmentGroups = equipmentGroups;
    }

    /**
     * 覆盖父类方法，主要让此id与officeId一致，用以一对一关联
     */
    @Override
    public void preInsert(){

        if (!this.isNewRecord){
            setId(office.getId());
        }
        User user = UserUtils.getUser();
        if (StringUtils.isNotBlank(user.getId())){
            this.updateBy = user;
            this.createBy = user;
        }
        this.updateDate = new Date();
        this.createDate = this.updateDate;
    }

}
